package com.ykzb.classify.dao.impl;

import com.ykzb.base.dao.impl.BaseDaoImpl;
import com.ykzb.classify.dao.IClassifyDao;
import com.ykzb.classify.mapper.ClassifyMapper;
import com.ykzb.classify.model.Classify;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Map;

@SuppressWarnings("restriction")
@Repository("classifyDao")
public class ClassifyDaoImpl extends BaseDaoImpl<Classify,Long> implements IClassifyDao
{
	private ClassifyMapper classifyMapper;

	@Autowired
	public void setClassifyMapper(ClassifyMapper classifyMapper)
	{
		this.classifyMapper = classifyMapper;
		setBaseMapper(classifyMapper);
	}

	@Override
	@Cacheable(value="classify")
	public List<Classify> selectClassify(Map<String, Object> param) {
		return classifyMapper.selectClassify(param);
	}

	@Override
	@Cacheable(value="classify")
	public Long selectIdByName(String name) throws Exception {
		if (name!=null){
			return classifyMapper.getIdByName(name);
		}
		return null;
	}

	@Override
	@Cacheable(value="classify")
	public String selectNameById(Long id) throws Exception {
		if (id!=null){
			return classifyMapper.getNameById(id);
		}
		return null;
	}


}